This has code for visualising what is happening with a multiple
regression. To run this yourself out of the Markdown, you’ll need to
install the package plotly, but the html should work fine
for you even if you don’t.
First, let’s visualise the model from where overall policy is predicted by both culture and move, but no interaction effect between the two predictors is included in the model.
##
## Call:
## lm(formula = overall ~ culture + move, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.044 -8.363 0.269 8.975 31.706
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -27.77263 5.65001 -4.916 1.68e-06 ***
## culture 0.59301 0.07245 8.185 1.83e-14 ***
## move 0.89113 0.05309 16.786 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 13.47 on 231 degrees of freedom
## Multiple R-squared: 0.5942, Adjusted R-squared: 0.5907
## F-statistic: 169.1 on 2 and 231 DF, p-value: < 2.2e-16
We can also visualise the model where overall policy is predicted by both culture and move, now with an interaction effect included.
##
## Call:
## lm(formula = overall ~ culture * move, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.866 -8.178 -0.139 8.728 30.069
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 16.624374 13.716776 1.212 0.226766
## culture -0.046725 0.194300 -0.240 0.810172
## move -0.171955 0.305168 -0.563 0.573660
## culture:move 0.015363 0.004346 3.535 0.000493 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 13.15 on 230 degrees of freedom
## Multiple R-squared: 0.6151, Adjusted R-squared: 0.6101
## F-statistic: 122.5 on 3 and 230 DF, p-value: < 2.2e-16